package com.greatwqs.wmall.product.provider.mapper;

import com.greatwqs.wmall.product.provider.model.po.Product;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * Created by MyBatis Generator 2025/04/01
 * https://github.com/greatwqs/mybatis-generator-plugin
 */
@Mapper
public interface ProductMapper {
    int deleteByProductId(Long productId);

    int insert(Product record);

    int insertSelective(Product record);

    Product selectByProductId(Long productId);

    List<Product> selectListByProductIds(List<Long> productIds);

    int updateByProductIdSelective(Product record);

    int updateByProductId(Product record);

    /**
     * 乐观锁扣减库存
     * @param subStock       扣减库存数量
     * @param currentStock   当前库存数量
     * @param currentVersion 当前版本号
     */
    int updateSubStockByProductId(Long productId, Integer subStock, Integer currentStock, Integer currentVersion);
}